package com.wang.wx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wang.wx.entity.EmailUser;
import com.wang.wx.entity.TwitterUser;
import com.wang.wx.entity.WxUser;
import com.wang.wx.entity.req.RequestDto;
import com.wang.wx.service.QueryService;
import com.wang.wx.service.TwitterUserService;
import com.wang.wx.service.WxUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjh
 * @create 2024-08-05 11:29
 */
@Service
public class QueryServiceImpl implements QueryService {
    
    @Resource
    private WxUserService wxUserService;
    @Resource
    private TwitterUserService twitterUserService;


    @Override
    public void complexQuery(RequestDto requestDto) {
        if (requestDto.getWxId() != null || !requestDto.getWxId().equals("")) {
            LambdaQueryWrapper<WxUser> wxWrapper = new LambdaQueryWrapper<>();
            wxWrapper.eq(WxUser::getWxId, requestDto.getWxId());
            List<WxUser> list = wxUserService.list(wxWrapper);
            if (list.size() != 0) {
                System.out.println("查询结果：" + list.get(0));
            } else {
                System.out.println("查询结果：" + "无");
            }
        }
        
        if (requestDto.getEmail() != null || !requestDto.getEmail().equals("")) {
            LambdaQueryWrapper<TwitterUser> twitterWrapper = new LambdaQueryWrapper<>();
            twitterWrapper.eq(TwitterUser::getEmail, requestDto.getEmail());
            List<TwitterUser> list = twitterUserService.list(twitterWrapper);
            if (list.size() != 0) {
                System.out.println("查询结果：" + list.get(0));
            } else {
                System.out.println("查询结果：" + "无");
            }
        }
    }
}
